Identifiers and Literals

An identifier in CSL has one of the following forms:

Simple Identifiers

A legal simple identifier consists of a letter (A-Z, a-z) or underscore (_) followed by any number of letters, numbers or underscores. Note that dashes (-) are not legal in identifiers (as they are interpreted as minus signs).  Also, unlike CSL Templates, identifiers in rules and formulas cannot include spaces.

Complex Identifiers

A complex identifier can have either of the following forms:

<simple-identifier>.<simple-identifier>[.<simple-identifier>]*

<function-invocation>.<simple-identifier>[.<simple-identifier>]*

See Simple Identifiers for information on simple identifiers. See Function Invocations for information on function invocations.

The function invocation or simple identifier to the left of the dot must be object valued.

A complex identifier can also have either of the following forms:

<simple-identifier>[string-literal]

<simple-identifier>[numerical-literal]

Note: The square brackets in the two lines above do not indicate optionality; they are not used as meta-characters, here; square brackets characters occur as part of these types of complex identifiers.

See Numerical Literals for information on numerical literals. See String Literals for information on string literals.

In these cases, the simple identifier to the left of the dot must be map valued. See also Map Functions.

Examples

part.totalCost

myFunction(5).id

myMap[3]

myMap[‘blue’]

Numerical Literals

There are three forms of numeric literals: integer, real and scientific.

  • Integer literals can begin with an optional sign (+,-) and consist of a sequence of digits (0-9)

  • Real literals can begin with an optional sign (+,-) followed by a sequence of digits (0-9) followed by a dot (.) followed by a sequence of digits (0-9). Note that if there is a dot there must be one digit to the right of it.  Thus "10." is not legal syntax, whereas "10.0" is.

  • Scientific literals follow the same rules as real literals with the addition of an 'e'  or 'E' followed by an optional sign followed by a sequence of (one or more) digits.

String Literals

Strings are enclosed by single quotes, ', and can contain any letter or digit except single quote, backslash, \n or \r. These characters (or character sequences) have to be escaped with a backslash. So, a string literal consisting of a single backslash followed by a single quote would be '\\\''.

Boolean Literals

There are two Boolean literals: true and false.